<template>
  <a-select
    v-model:value="currentLang"
    style="width: 120px"
    @change="handleLangChange"
  >
    <a-select-option value="zh-CN">中文</a-select-option>
    <a-select-option value="en-US">English</a-select-option>
  </a-select>
</template>

<script setup>
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { message } from 'ant-design-vue'

const { locale } = useI18n()
const currentLang = ref(localStorage.getItem('language') || 'zh-CN')

const handleLangChange = lang => {
  locale.value = lang
  localStorage.setItem('language', lang)
  message.success('语言切换成功')
}
</script>